//
//  LCBaseViewController.m
//  ShopStore
//
//  Created by 东亨 on 2017/4/27.
//  Copyright © 2017年 lichao. All rights reserved.
//

#import "LCBaseViewController.h"
#import "BaseNavigationController.h"
#import "LCHomeViewController.h"
#import "LCServiceViewController.h"
#import "LCConViewController.h"
#import "LCPersonViewController.h"
#import "RDVTabBarItem.h"
@interface LCBaseViewController ()
@property(nonatomic,assign)NSInteger  indexFlag;
@end

@implementation LCBaseViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    [[UITabBar appearance] setBarTintColor:[UIColor colorWithHex:0xfcfcfc]];
    [UITabBar appearance].translucent = NO;//不让系统渲染保持原色
    [self setupViewControllers];
}
- (void)setupViewControllers {
    UINavigationController *nav1 = [[UINavigationController alloc]initWithRootViewController:[[LCHomeViewController alloc] init]];
    UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:[[LCServiceViewController alloc] init]];
    UINavigationController *nav3 = [[UINavigationController alloc]initWithRootViewController:[[LCConViewController alloc] init]];
    UINavigationController *nav4 = [[UINavigationController alloc]initWithRootViewController:[[LCPersonViewController alloc] init]];
     nav1.navigationBar.hidden = YES;
     nav2.navigationBar.hidden = YES;
     nav3.navigationBar.hidden = YES;
     nav4.navigationBar.hidden = YES;
    [self setViewControllers:@[nav1, nav2, nav3, nav4]];
    //设置tabitem的图片
    NSArray *tabBarItemImages = @[@"home", @"social", @"property",@"person", @"me"];
    NSArray *tabBarTitles = @[@"首页",@"政策服务",@"资讯服务",@"个人中心"];
    NSDictionary *selectedTitleAttributes = @{NSForegroundColorAttributeName:[UIColor colorWithHex:0xd9534f]};
    NSDictionary *unselectedTitleAttributes = @{NSForegroundColorAttributeName:[UIColor colorWithHex:0xa8a8a8]};
    NSInteger index = 0;
    for (RDVTabBarItem *item in [[self tabBar] items]){
        UIImage *selectedImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_se",
                                                      [tabBarItemImages objectAtIndex:index]]];
        UIImage *normalImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_no",
                                                    [tabBarItemImages objectAtIndex:index]]];
        [item setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:normalImage];
        [item setTitle:[tabBarTitles objectAtIndex:index]];
        [item setSelectedTitleAttributes:selectedTitleAttributes];
        [item setUnselectedTitleAttributes:unselectedTitleAttributes];
        index++;
    }
}
@end
